﻿using System;
using System.Data ;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows .Forms ;
using System.ComponentModel;

namespace RuleCode.Common
{

    #region ButtonClickEventArg
    /// <summary>
    /// 跳出窗体事件参数 以及 字段 LookUp 事件参数
    /// </summary>
    public class ButtonClickEventArg
    {
        public ButtonClickEventArg()
        {
            this.Cancel = false;
        }

        public ButtonClickEventArg(bool cancel)
        {
            this.Cancel = cancel;
        }


        private bool cancel;
        /// <summary>
        /// 获取或设置 是否取消执行以后的事件
        /// </summary>
        public bool Cancel
        {
            get { return this.cancel; }
            set { this.cancel = value; }
        }


    }
    #endregion

    #region ValueEventArgs
    public class ValueEventArgs : EventArgs
    {
        /// <summary>
        /// 空值的ValueEventArgs
        /// </summary>
        public static ValueEventArgs NULL = new ValueEventArgs();

        public ValueEventArgs()
            : base()
        {
            this.newValue = "";
        }
        public ValueEventArgs(object value)
        {
            this.newValue = value;
        }

        private object newValue;
        /// <summary>
        /// 将要更改的新值
        /// </summary>
        public object NewValue
        {
            get { return this.newValue; }
            set { this.newValue = value; }
        }

    }
    #endregion

    #region  LookUpEventArg
    public class LookUpEventArg : EventArgs
    {
        #region 属性
        private string fieldName;
        /// <summary>
        /// 获取或设置 字段名称
        /// </summary>
        public string FieldName
        {
            get { return this.fieldName; }
            set { this.fieldName = value; }
        }

        private string tableName;
        /// <summary>
        /// 获取或设置表的名称
        /// </summary>
        public string TableName
        {
            get { return this.tableName; }
            set { this.tableName = value; }
        }
        #endregion

        #region 构造函数
        public LookUpEventArg()
        {
            this.tableName = "";
            this.fieldName = "";
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="fName">字段名称</param>
        /// <param name="tName">表的名称</param>
        public LookUpEventArg(string fName, string tName)
        {
            this.fieldName = fName;
            this.tableName = tName;
        }
        #endregion
    }
    #endregion

    #region TableInitEvnetArg
    public class TableInitEventArg : EventArgs
    {
    }
    #endregion
    #region TableInitEvnetArg
    public class AftNewEventArg : EventArgs
    {
    }
    #endregion
    #region PreFetchEventArg
    public class PreFetchEventArg : EventArgs
    {
    }
    #endregion
    #region AftFetchEventArg
    public class AftFetchEventArg : EventArgs
    {
    }
    #endregion


    #region OnEorror
    public class OnErrorArg : CancelEventArgs
    {
        public string Ex { get; set; }
    }
    #endregion


    #region PreModifyEventArg
    public class PreModifyEventArg : CancelEventArgs
    {
        /// <summary>
        /// 获取或设置 为修改单元格（ColumnIndex，RowIndex）所设置的新值
        /// </summary>
        public object ProposedValue { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的列索引
        /// </summary>
        public int ColumnIndex { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的行索引
        /// </summary>
        public int RowIndex { get; set; }

        public PreModifyEventArg()
            : base()
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }
        public PreModifyEventArg(bool cancel)
            : base(cancel )
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }

        public PreModifyEventArg(int clomunIndex,int rowIndex)
            : base()
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }

        public PreModifyEventArg(int clomunIndex, int rowIndex,bool cancel)
            : base(cancel)
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }

        public PreModifyEventArg(int columnIndex, int rowIndex, bool cancel, object proposedValue)
            : this(columnIndex, rowIndex, cancel)
        {
            this.ProposedValue = proposedValue;
        }

    }
    #endregion

    #region AftModifyEventArg
    public class AftModifyEventArg : EventArgs
    { 
        /// <summary>
        /// 获取或设置 表改变时的列索引
        /// </summary>
        public int ColumnIndex { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的行索引
        /// </summary>
        public int RowIndex { get; set; }

        public AftModifyEventArg()
            : base()
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }
       
        public AftModifyEventArg(int clomunIndex,int rowIndex)
            : base()
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }
    }
    #endregion 

    #region PreInsertEventArg
    public class PreInsertEventArg : CancelEventArgs
    {
        /// <summary>
        /// 获取或设置 将要插入的行
        /// </summary>
        public DataRow Row { get; set; }

        public PreInsertEventArg(): base() { }

        public PreInsertEventArg(bool cancel) : base(cancel) { }

        public PreInsertEventArg(DataRow row) : base() { this.Row = row; }

        public PreInsertEventArg(DataRow row, bool cancel) : base(cancel) { this.Row = row; }
    }
    #endregion

    #region AftInsertEventArg
    public class AftInsertEventArg : EventArgs
    {
         /// <summary>
        /// 获取或设置 将要插入的行
        /// </summary>
        public DataRow Row { get; set; }

        public AftInsertEventArg(): base() { }

        public AftInsertEventArg(DataRow row) : base() { this.Row = row; }
    }
    #endregion 

    #region PreDeleteEventArg
    public class PreDeleteEventArg : CancelEventArgs
    {
        /// <summary>
        /// 获取或设置 将要删除的行
        /// </summary>
        public DataRow Row { get; set; }

        /// <summary>
        /// 获取或设置 将要删除的行在原来的表中的索引
        /// </summary>
        public int OldRowIndex { get; set; }

        public PreDeleteEventArg()
            : base()
        {
        }
        public PreDeleteEventArg(bool cancel)
            : base(cancel)
        {
        }

        public PreDeleteEventArg(DataRow row)
            : this()
        {
            this.Row = row;
        }
           

        public PreDeleteEventArg(DataRow row, bool cancel)
            : this(cancel)
        {
            this.Row = row;
        }

        public PreDeleteEventArg(DataRow row, bool cancel, int oldRowIndex)
            : this(row, cancel)
        {
            this.OldRowIndex = oldRowIndex;
        }
    }
    #endregion

    #region AftDeleteEventArg
    public class AftDeleteEventArg : EventArgs
    {
        /// <summary>
        /// 获取或设置 已经删除的行
        /// </summary>
        public DataRow Row { get; set; }

        /// <summary>
        /// 获取或设置 将要删除的行在原来的表中的索引
        /// </summary>
        public int OldRowIndex { get; set; }


        public AftDeleteEventArg()
            : base()
        {
            
        }

        public AftDeleteEventArg(DataRow row)
            : this()
        {
            this.Row = row;
        }

        public AftDeleteEventArg(DataRow row, int oldRowIndex)
            : this(row)
        {
            this.OldRowIndex = oldRowIndex;
        }
    }
    #endregion 

    #region PreUpdateEventArg
    public class PreUpdateEventArg : CancelEventArgs
    {
        /// <summary>
        /// 获取或设置 更新操作
        /// </summary>
        public UpdateAction UpdateAction { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的列索引
        /// </summary>
        public int ColumnIndex { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的行索引
        /// </summary>
        public int RowIndex { get; set; }

        public PreUpdateEventArg()
            : base()
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }
        public PreUpdateEventArg(UpdateAction updateAction)
            : base()
        {
            this.UpdateAction = updateAction;
        }

        public PreUpdateEventArg(bool cancel)
            : base(cancel)
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }

        public PreUpdateEventArg(int clomunIndex, int rowIndex)
            : base()
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }

        public PreUpdateEventArg(int columnIndex, int rowIndex, UpdateAction updateAction)
            : this(columnIndex, rowIndex)
        {
            this.UpdateAction = updateAction;
        }

        public PreUpdateEventArg(int clomunIndex, int rowIndex, bool cancel)
            : base(cancel)
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }

        public PreUpdateEventArg(int columnIndex, int rowIndex, bool cancel, UpdateAction updateAction):this(columnIndex ,rowIndex ,cancel )
        {
            this.UpdateAction = updateAction;
        }
    }
    #endregion

    #region AftUpdateEventArg
    public class AftUpdateEventArg : EventArgs
    {
        /// <summary>
        /// 获取或设置 更新操作
        /// </summary>
        public UpdateAction UpdateAction { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的列索引
        /// </summary>
        public int ColumnIndex { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的行索引
        /// </summary>
        public int RowIndex { get; set; }

        public AftUpdateEventArg()
            : base()
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }

        public AftUpdateEventArg(int clomunIndex, int rowIndex)
            : base()
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }

        public AftUpdateEventArg(UpdateAction updateAction)
            : this()
        {
            this.UpdateAction = updateAction;
        }

        public AftUpdateEventArg(int columnIndex, int rowIndex, UpdateAction updateAction)
            : this(columnIndex, rowIndex)
        {
            this.UpdateAction = updateAction;
        }
    }
    #endregion 

    #region PreValidateEventArg
    public class PreValidateEventArg : CancelEventArgs
    {
        /// <summary>
        /// 获取或设置 表改变时的列索引
        /// </summary>
        public int ColumnIndex { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的行索引
        /// </summary>
        public int RowIndex { get; set; }

        public PreValidateEventArg()
            : base()
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }
        public PreValidateEventArg(bool cancel)
            : base(cancel)
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }

        public PreValidateEventArg(int clomunIndex, int rowIndex)
            : base()
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }

        public PreValidateEventArg(int clomunIndex, int rowIndex, bool cancel)
            : base(cancel)
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }
    }
    #endregion

    #region AftValidateEventArg
    public class AftValidateEventArg : EventArgs
    {
        /// <summary>
        /// 获取或设置 表改变时的列索引
        /// </summary>
        public int ColumnIndex { get; set; }

        /// <summary>
        /// 获取或设置 表改变时的行索引
        /// </summary>
        public int RowIndex { get; set; }

        public AftValidateEventArg()
            : base()
        {
            this.ColumnIndex = -1;
            this.RowIndex = -1;
        }

        public AftValidateEventArg(int clomunIndex, int rowIndex)
            : base()
        {
            this.ColumnIndex = clomunIndex;
            this.RowIndex = rowIndex;
        }
    }
    #endregion 
}
